﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.ComponentModel;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TNOWS
    {
        public TNOWS()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWASTAMM();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwWS = dwMaster;
            if (dwMaster == null)
            {
                KEY = "";
                TXTISIND = "";
            }
            else
            {
                KEY = TMV.WAART + TMV.WAVAR;
                TXTISIND = ("00000000      " + TMV.WAART + TMV.WAVAR).PadRight(60);
            }
        }
        public override void LOADBYAUF()
        {
            base.LOADBYAUF();
            if (ORDERNUM.Trim().Length == 0)
                return;
            if (TBMain.Rows.Count > 0)
                return;
            dwData = TBMain.NewRow();
            TMV.SetUpNewRow(ref dwData);
            dwData["WAMANDANT"] = app.Mandant;
            dwData["WAFKZ"] = "J";
            dwData["WAART"] = ORDERNUM.Substring(1,20);
            dwData["WAVAR"] = ORDERNUM.Substring(21, 2);
            dwData["WABEZ"] = ORDERNUM.Substring(23).Trim().PadRight(40);
            TMV.Insert(dwData);
            vwMaster.View.MoveCurrentToFirst();
        } 
    }
}
